﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAWSharp.DSP.Dynamics
{
    /// <summary>
    /// DSP to downsample to 8 bit
    /// </summary>
    public class EightBit
    {
        /// <summary>
        /// Downsamples a sample to 8 bit
        /// </summary>
        /// <param name="input">Sample To Process</param>
        /// <returns>Processed Sample</returns>
        public float Process(float input)
        {
            int sixteenBit = (int)(input * 32767);
            int eightBit = (int)(sixteenBit / 256);
            return (float)(eightBit / 127.0);
        }
    }
}
